<?php

/**
* Date Helper Extension
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package		Jobba The Site
* @author		SSA
* @copyright	        Copyright (c) 2008, SSA.
* @license		GPL v2.0
* @link		http://shoestringarchitects.com
* @since		Version 1.0
* @filesource
*/



/**
* next_year
*
* Returns the value of the year following the present year or the date
* as of 365 days ahead of the present.
* @access	public
* @param	format	format of the date returned, default is 'Y'.
*/

function next_year($format = 'Y') {
	 return date($format, time() + 31536000);
}



/**
* plural
*
* Returns the plural form of the number if it needs to.
* This is only supposed to be accessed by relative_time.
*
* @access	public
* @param	num	the number that is going to be checked
*/

function _plural($num) {
        if ($num <> 1){
            return "s";
        }
    }

/**
* relative_time
*
* Returns the relative time to now.
*
* @access	public
* @param	date	The date that is going to be changed
*/
function relative_time($date) {
        $diff = time() - strtotime($date);
        if ($diff<60)
		  //Modified by Gavin:
                //{return $diff . " second" . _plural($diff) . " ago";}
		{ return "Today"; }
        $diff = round($diff/60);
        if ($diff<60)
		  //Modified by Gavin:
		  //{return $diff . " minute" . _plural($diff) . " ago";}
		  { return "Today"; }
        $diff = round($diff/60);
        if ($diff<24)
		  //Modified by Gavin:
                //{return $diff . " hour" . _plural($diff) . " ago";}
		  { return "Today"; }
        $diff = round($diff/24);
        if ($diff<7)
                {return $diff . " day" . _plural($diff) . " ago";}
        $diff = round($diff/7);
        if ($diff<4)
                {return $diff . " week" . _plural($diff) . " ago";}
        return "On " . date("F j, Y", strtotime($date));
}


?>